<h3>
    {$title}
</h3>
<div class="filter">
    <form action="{:U(GROUP_NAME.'/Daikuan/index')}" method="post">
        <input name="keyword" type="text" placeholder="用户名" class="inpMain" value="{$keyword}" size="20" />
        <input name="submit" class="btnGray" type="submit" value="筛选" />
    </form>
</div>
<div id="list">
        <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
            <tr>
                <th width="50" align="center">ID</th>
                <th width="120" align="center">订单号</th>
                <th width="80" align="center">用户名</th>
                <th width="80" align="center">姓名</th>
                <th width="70">借款金额</th>
                <th width="70">借款期限</th>
                <th width="75" align="center">创建日期</th>
                <th width="75" align="center">邀请码</th>
                <th width="80">状态</th>
                <th align="center">操作</th>
            </tr>
            <volist name="list" id="vo">
                <tr>
                    <td align="center">{$vo.id}</td>
                    <td align="center">{$vo.ordernum}</td>
                    <td align="center">{$vo.user}</td>
                    <td align="center">{$vo.name}</td>
					<td align="center">{$vo.money}元</td>
					<td align="center">{$vo.months}月</td>
                    <td align="center">{$vo.addtime|date='Y-m-d H:i:s',###}</td>
                    <td align="center">{$vo.code}</td>
                    <td align="center">
						<php>
							if($vo['status'] == 0)echo "订单创建成功";
							if($vo['status'] == 1)echo "审核通过";
							if($vo['status'] == 2)echo "订单提现成功";
							if($vo['status'] == '-1')echo "审核不通过";
						</php>
                    </td>
                    <td align="center">
                    <a href="javascript:change_money('{$vo.ordernum}','{$vo.money}','{$vo.id}');">改额度</a> |
                    <a href="__URL__/send_sms?id={$vo.id}">发短信</a> |
                    <a href="javascript:set_code('{$vo.ordernum}','{$vo.id}');">邀请码</a> |
                    	<a href="javascript:changestatus('{$vo.ordernum}','{$vo.id}');">修改状态</a> |
                    	<a href="javascript:showbank('{$vo.bank}','{$vo.banknum}');">打款信息</a> |
                        <a href="javascript:del('{$vo.ordernum}','{:U(GROUP_NAME.'/Daikuan/del',array('id'=>$vo['id']))}');">删除</a>
                    </td>
                </tr>
            </volist>
        </table>
</div>
<div class="clear"></div>
<div class="pager">
    {$page}
</div>
</div>
<script>
    function del(num,jumpurl){
        layer.confirm(
                '确定要删除借款订单:'+num+'吗?',
                function (){
                    window.location.href = jumpurl;
                }
        );
    }
    function showbank(bankname,banknum){
  		layer.alert(
  			'打款银行:' + bankname + "<br>" + '银行卡号:' + banknum,
  			{
	    		skin: 'layui-layer-lan',
	    		closeBtn: 0,
	    		anim: 4
  			}
  		);
    }
	
    function changestatus(ordernum,oid){
    	$("#changestatus_span").html(ordernum);
    	$("#orderid").val(oid);
		layer.open({
		  	type: 1,
		  	skin: 'layui-layer-rim', //加上边框
		  	area: ['500px', '165px'], //宽高
		  	content: $("#changestatus_div").html()
		});
    }
    function savestatus(){
    	var id = $("#orderid").val();
    	var status = $('input:radio[name="status"]:checked').val();
    	if(status != 'undefined' && status != '' && status != null){
    		$.post(
    			"{:U(GROUP_NAME.'/Daikuan/changestatus')}",
    			{id:id,status:status},
    			function(data,state){
    				if(state != "success"){
    					layer.msg("请求数据失败!");
    				}else if(data.status == 1){
    					layer.msg("保存成功!");
    					setTimeout(function(){
    						window.location.href = window.location.href;
    					},2000);
    				}else{
    					layer.msg(data.msg);
    				}
    			}
    		);
    	}else{
    		layer.msg("请选择订单状态!");
    	}
    }
	
	function set_code(ordernum,oid){
		$("#changestatus_spans").html(ordernum);
    	$("#orderids").val(oid);
		layer.open({
		  	type: 1,
		  	skin: 'layui-layer-rim', //加上边框
		  	area: ['500px', '165px'], //宽高
		  	content: $("#set_code").html()
		});
    }
	 function save_code(){
    	var id = $("#orderids").val();
		var code=$("#tt").val();
    	if(code != ''){
    		$.post(
    			"{:U(GROUP_NAME.'/Daikuan/save_code')}",
    			{id:id,code:code},
    			function(data,state){
    				if(state != "success"){
    					layer.msg("请求数据失败!");
    				}else if(data.status == 1){
    					layer.msg("保存成功!");
    					setTimeout(function(){
    						window.location.href = window.location.href;
    					},2000);
    				}else{
    					layer.msg(data.msg);
    				}
    			}
    		);
    	}else{
    		layer.msg("请填写邀请码!");
    	}
    }
	
	function change_money(ordernum,money,oid){
		$("#order_sn").html(ordernum);
		$("#order_money").val(money);
    	$("#orderids_s").val(oid);
		layer.open({
		  	type: 1,
		  	skin: 'layui-layer-rim', //加上边框
		  	area: ['500px', '165px'], //宽高
		  	content: $("#change_money").html()
		});
    }
	
	function save_change_money(){
    	var id = $("#orderids_s").val();
		var c_money=$("#c_money").val();
    	if(c_money != ''){
    		$.post(
    			"{:U(GROUP_NAME.'/Daikuan/save_change_money')}",
    			{id:id,c_money:c_money},
    			function(data,state){
    				if(state != "success"){
    					layer.msg("请求数据失败!");
    				}else if(data.status == 1){
    					layer.msg("保存成功!");
    					setTimeout(function(){
    						window.location.href = window.location.href;
    					},2000);
    				}else{
    					layer.msg(data.msg);
    				}
    			}
    		);
    	}else{
    		layer.msg("请填写邀请码!");
    	}
    }
</script>
<div style="display: none;" id="changestatus_div">
    <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
        <tr>
            <td width="100" align="right">订单号</td>
            <td>
                <span id="changestatus_span"></span>
                <input type="hidden" id="orderid" value="" />
            </td>
        </tr>
        <tr>
            <td align="right">状态</td>
            <td>
                <label>
                    <input type="radio" name="status" value="0"  >
					创建成功
                </label>
                <label>
                    <input type="radio" name="status" value="1"  >
					审核通过
              </label>
                <label>
                    <input type="radio" name="status" value="2"  >
					成功放款
              </label>
              <label>
                    <input type="radio" name="status" value="3"  >
					成功提现
              </label>
                <label>
                    <input type="radio" name="status" value="-1"  >
					审核不通过
                </label>
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="submit" onclick="savestatus();" class="btn" value="提交" />
            </td>
        </tr>
    </table>
</div>

<div style="display: none;" id="set_code">
    <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
        <tr>
            <td width="100" align="right">订单号</td>
            <td>
              <span id="changestatus_spans"></span>
              <input type="hidden" id="orderids" value="" />
            </td>
        </tr>
        <tr>
            <td align="right">借款金额</td>
            <td>
              <input type="text" value="" name="code" onblur="ccc(this.value);" id="codes" />
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
            	
              <input type="submit" onclick="save_code();" class="btn" value="提交" />
            </td>
        </tr>
    </table>
</div>
<input type="hidden" id="tt" value="" />
<input type="hidden" id="c_money" value="" />

<div style="display: none;" id="change_money">
    <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
        <tr>
            <td width="100" align="right">订单号</td>
            <td>
              <span id="order_sn"></span>
              <input type="hidden" id="orderids_s" value="" />
            </td>
        </tr>
        <tr>
            <td align="right">额度</td>
            <td>
              <input type="text" value="" name="order_money" onblur="ddd(this.value);" id="order_money" />
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
            	
              <input type="submit" onclick="save_change_money();" class="btn" value="提交" />
            </td>
        </tr>
    </table>
</div>
<script>
function ccc(vv){
	$("#tt").val(vv);
}
function ddd(vv){
	$("#c_money").val(vv);
}

</script>